package cn.appsys.total;

import cn.appsys.pojo.BackendUser;
import cn.appsys.pojo.DevUser;
import lombok.extern.log4j.Log4j;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@Log4j
public class backSysInterceptor  extends HandlerInterceptorAdapter {
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws  Exception{
        log.debug("进入管理员拦截器==");
        HttpSession session=request.getSession();
        String url=request.getRequestURI();
        if(url.indexOf("back/toLogin")>0||url.indexOf("back/login")>0||url.indexOf("lanjie")>0||url.indexOf("statics")>0){
            return true;
        }
        BackendUser backendUser=(BackendUser) session.getAttribute("userSession");
        if(null!=backendUser){
            return true;
        }
        response.sendRedirect(request.getContextPath()+"/lanjie");
        return false;
    }
}
